package com.cwx.mychat.utils.copy;

import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class CopyUtils {

    public static <T, S> List<T> copyList(List<S> list, Class<T> clazz){
        List<T> arrayList = new ArrayList<>();
        for(S s: list){
            T t = null;
            try {
                t = clazz.newInstance();
            }catch (Exception e){
                e.printStackTrace();
            }
            BeanUtils.copyProperties(s, t);
            arrayList.add(t);
        }
        return arrayList;
    }
}
